# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# disasm_bin directory
set(DISASM_BIN_DIR ${CMAKE_CURRENT_BINARY_DIR})

# disasm_tests directory
set(DISASM_ECMA_TESTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/sources)

set(LITERALS_TEST_ECMA_SRC ${CMAKE_CURRENT_BINARY_DIR}/disasm_test_lit_ecma.cpp)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/disasm_test_lit_ecma.cpp.in ${LITERALS_TEST_ECMA_SRC} @ONLY)

panda_ecmascript_add_gtest(
    NAME
        disasm_tests_ecma
    SOURCES
        ${LITERALS_TEST_ECMA_SRC}
    LIBRARIES
        arkdisassembler
    INCLUDE_DIRS
        ${PANDA_ROOT}/disassembler
    SANITIZERS
        ${PANDA_SANITIZERS_LIST}
)

set(DISASM_LIT_BINARY ${DISASM_BIN_DIR}/lit.bc)
set(DISASM_LIT_SRC ${DISASM_ECMA_TESTS_DIR}/lit.js)
compile_file_ecma(FILE ${DISASM_LIT_SRC} OUTPUT_FILE ${DISASM_LIT_BINARY} WORKING_DIR ${DISASM_BIN_DIR})
add_custom_target(disasm_tests_binaries DEPENDS ${DISASM_LIT_BINARY})
add_dependencies(disasm_tests_ecma disasm_tests_binaries)
